package com.weishi.project.sport.mine.controller;

import com.weishi.framework.web.controller.BaseController;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.project.sport.mine.service.MineService;
import com.weishi.project.training.domain.Sportsman;
import com.weishi.project.training.domain.SportsmanBodyShape;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "运动员端--我的--个人中心模块", description = "运动员端--我的--个人中心模块")
@RestController
@CrossOrigin("*")//解决移动端跨域
@RequestMapping("/sportMine/")
public class MineController extends BaseController {


    /**
     * 运动员个人中心模块 接口
     */
    @Autowired
    private MineService mineService;


    @ApiOperation("查询运动员个人基本信息--( 比赛次数，和 累计训练次数 )")
    @RequestMapping(value = "getMineDetails", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getMineDetails()
    {
        return mineService.getMineDetails(currentLoginSportsman().getId());
    }


    @ApiOperation("查询运动员个人状态")
    @RequestMapping(value = "getMineState", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getMineState()
    {
        return mineService.getMineState(currentLoginSportsman().getId());
    }


    @ApiOperation("查询运动员个人身体机能数据")
    @RequestMapping(value = "getMineBodyFunction", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getMineBodyFunction()
    {
        return mineService.getMineBodyFunction(currentLoginSportsman().getId());
    }


    @ApiOperation("查询运动员个人身体形态数据详情 -- 折线图")
    @RequestMapping(value = "getMineStateDetails", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getMineStateDetails()
    {
        return mineService.getMineStateDetails(currentLoginSportsman().getId());
    }


    @ApiOperation("查询运动员个人物理属性列表")
    @RequestMapping(value = "getBodyFunction", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getBodyFunction()
    {
        return mineService.getBodyFunction(currentLoginSportsman().getId());
    }


    @ApiOperation("运动员个人信息修改")
    @RequestMapping(value = "updateById", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult updateById(Sportsman sportsman)
    {
        return mineService.updateById(currentLoginSportsman().getId() , sportsman);
    }


    @ApiOperation("运动员个人 -- 新增身体形态数据")
    @RequestMapping(value = "save", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult save(SportsmanBodyShape sportsmanBodyShape)
    {
        return mineService.save(currentLoginSportsman().getId() , sportsmanBodyShape);
    }


    @ApiOperation("运动员个人 -- 查询身体形态字典子表数据")
    @RequestMapping(value = "getDictData", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getDictData()
    {
        return mineService.getDictData();
    }


    @ApiOperation("运动员个人 -- 查询身体机能---折线图")
    @RequestMapping(value = "getBodyFunctionLineChart", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult getBodyFunctionLineChart()
    {
        return mineService.getBodyFunctionLineChart(currentLoginSportsman().getId());
    }












}
